﻿#include "GLLInc.h"
#include "GLLSignal.h"

namespace GLL
{

	Signal::Signal()
	{
#ifdef GLL_WIN
		_handle = CreateSemaphore(NULL, 0, 1, NULL);
		if (_handle == NULL) 
		{
			SS strm;
			strm << "CreateMutex error: " << GetLastError();
			GLL_Throw(strm);
		}
#endif GLL_WIN
	}

	void Signal::Wait()
	{
#ifdef GLL_WIN
		WaitForSingleObject(_handle, INFINITE);
#endif GLL_WIN
	}

	void Signal::Notify()
	{
#ifdef GLL_WIN
		ReleaseSemaphore(_handle, 1, 0);
#endif GLL_WIN

	}

	Signal::~Signal()
	{
#ifdef GLL_WIN
		CloseHandle(_handle);
#endif GLL_WIN

	}
};//GLL
